/**
 * 
 */
package edu.wpi.cs509.messages.client;

import edu.wpi.cs509.representation.ActionBaseClass;
import edu.wpi.cs509.representation.ClientGame;
import edu.wpi.cs509.representation.TeamColor;

/**
 * This class implements the server->client game-over message.
 * @author sparadis
 *
 */
public class MsgGameOver extends MsgGameUpdate {

	/**
	 * The serialization version ID.
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * game: the updated client game instance
	 * winner: true if this client won the game.
	 */
	protected boolean winner; 
	protected ClientGame game;
	
	/**
	 * Constructor.
	 * @param userSession - this client's user session
	 * @param winner - true if this client was the winner.
	 */
	public MsgGameOver(ClientGame game, ActionBaseClass move, boolean winner) {
		//TeamColor is a no-op here. Could use TeamColor.UNKNOWN or 
		//TeamColor.SPECTATOR instead of red.
		super(game, move, TeamColor.RED);
		
		this.winner = winner;
		this.game = game;
	}
	
	/**
	 * Call the client's game-over function. 
	 */
	public void rxExecute() {
		getCl().receiveGameOver(game, winner);
	}
	
}
